all: swagger uml clean build

wire:
	wire ./app
clean:
	rm -rf assets
	rm -f app/asset.go
	rm -rf dist
app/asset.go: assets
	go-bindata -o=app/asset.go -pkg=app ./assets/...
assets:
	mkdir assets
	npm --prefix display run build
	cp -f templates/*.tmpl ./assets
	cp -f files/*.png ./assets
	cp -f *.toml ./assets
	rm -f ./assets/*.txt
uml:
	goplantuml -title screens -output doc/screens.puml app pb
swagger:
	swagger generate spec -o ./doc/swagger.yaml -m
proto: protojs
	protoc --go_out=. pb/*.proto
protojs:
	display/node_modules/.bin/pbjs -t static-module -w commonjs -o display/src/pb.js pb/*.proto
	display/node_modules/.bin/pbts -o display/src/pb.d.ts display/src/pb.js
build: app/asset.go proto wire
	mkdir dist
	CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/ds.exe main.go
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/ds-linux main.go
	CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/ds-darwin main.go
vendor:
	go mod vendor
tslint:
	tslint -c display/tslint.json display/src/**/*.ts
lint: tslint
	golangci-lint run
